using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using ContentBanner.Models;
using Orchard.Localization;

namespace ContentBanner.Handlers {
    public class ContentBannerSettingsHandler : ContentHandler {
        public ContentBannerSettingsHandler (IRepository<ContentBannerSettingsPartRecord> repository)
        {
            Filters.Add(new ActivatingFilter<ContentBannerSettingsPart>("Site"));
            Filters.Add(StorageFilter.For(repository));
        }

        public Localizer T { get; set; }

        protected override void GetItemMetadata(GetContentItemMetadataContext context)
        {
            if (context.ContentItem.ContentType != "Site")
            {
                return;
            }
            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Content Banner")));
        }
    }
}